<?php
/* [DoYouHaoBaby!] (C)Dianniu From 2010.
   this($)*/

!defined('DYHB_PATH') && exit;

class TemplateGtkGladeWidgetCompiler_GtkPaned extends TemplateGtkGladeWidgetCompilerBase{

	private $_nChildIdxe=0;

	protected function compileCreateWidget_(TemplateGtkGladeWidget $oObject){
		$sWidgetClass=$oObject->getWidgetClass();// GtkHBox, GtkVBox
		$sVariableName='$'.TemplateGtkGlade::getWidgetVariableName($oObject);
		$sCompiled =
"		{$sVariableName}=new {$sWidgetClass}();
";
		if(TemplateGtkGladeObj::nodeTextToValue($oObject->getProperty('position_set'))){
			if(($sValue=$oObject->getProperty('position'))===null)
				$sValue='0';
			$sCompiled.="\t\t{$sVariableName}->set_position({$sValue});";
		}
		$this->_nChildIdxe=0;
		return $sCompiled;
	}

	protected function compileChildWidgetPacking_(TemplateGtkGladeWidget $oParentWidget,TemplateGtkGladeWidget $oChildWidget,TemplateGtkGladeWidgetPacking $oPacking){
		$sParentVariableName='$'.TemplateGtkGlade::getWidgetVariableName($oParentWidget);
		$sChildWidgetVariableName='$'.TemplateGtkGlade::getWidgetVariableName($oChildWidget);
		$sChildWidgetId=$oChildWidget->getWidgetId();
		$sCompiled="\t\t{$sChildWidgetVariableName}=\$this->getWidget('{$sChildWidgetId}',\$arrObjectForSignal);";
		$sCompiled.=sprintf("\t\t{$sParentVariableName}->add%d({$sChildWidgetVariableName});",++$this->_nChildIdxe);
		return $sCompiled;
	}

	static public function regToProcessorManager(ITemplateObjProcessorManager $oManager){
		$oManager->regProcessor(str_replace('TemplateGtkGladeWidgetCompiler_','',__CLASS__),__CLASS__);
	}

}
